package at.evonfc.db;

import java.util.ArrayList;
import java.util.HashMap;

import at.evonfc.data.Device;

public class DBSession {
	private static final ArrayList<Object> databaseObjects = new ArrayList<Object>();
	private static final HashMap<String, String> userNames = new HashMap<String, String>();
	
	public static void addObject(Object obj) {
		databaseObjects.add(obj);
	}
	
	public static void addUser(String id, String name) {
		userNames.put(id, name);
	}
	
	public static String getUserName(String id) {
		return userNames.get(id);
	}
	
	public static Device getDevice(int id) {
		for(Object obj : databaseObjects) {
			if(obj instanceof Device) {
				if(id == ((Device)obj).getId()) {
					return (Device)obj;
				}
			}
		}
		return null;
	}
}
